<?php
define('LOG_EMERG',1);
define('LOG_ALERT',2);
define('LOG_CRITICAL',5);
define('LOG_ERROR',10);
define('LOG_WARNING',25);
define('LOG_NOTICE',50);
define('LOG_INFO',75);
define('LOG_DEBUG',100);

class Log
{
	static protected function _classExists($class)
	{
		return class_exists($class);
	}
	
	static public function &factory($handler,$name='',$conf=array(),$level='')
	{
		$handler=strtolower($handler);
		$class='Log_'.$handler;
		$classfile='mods/log_'.$handler.'.php';
		
		if (!Log::_classExists($class)) {
			include_once $classfile;
		}
		
		if (Log::_classExists($class)) {
			$obj=&new $class($name);
			return $obj;
		}
		
		return null;
	}
	
	static public function &singleton($handler,$name='',$conf=array(),$level='')
	{
		static $instances;
		if (!isset($instances)) $instances=array();
		$signature=serialize(array($handler,$name));
		if (!isset($instances[$signature]))	{
			$instances[$signature]=&Log::factory($handler,$name);
		}
		echo '<pre>';var_dump($instances);echo '</pre>';
		return $instances[$signature];
	}

	public function log($message,$priority=null)
	{
		return false;
	}
}
?>